<html>
<head>
<title>Sample Application for RSA signing in JavaScript</title>
<script language="JavaScript" type="text/javascript" src="./jsrsasign-all-min.js"></script>
<script language="JavaScript" type="text/javascript">
function doSign() {
  /* var rsa = new RSAKey();
  rsa.readPrivateKeyFromPEMString(document.form1.prvkey1.value);
  var hashAlg = document.form1.hashalg.value;
  var hSig = rsa.sign(document.form1.msgsigned.value, hashAlg);
  document.form1.siggenerated.value = linebrk(hSig, 64); */
  	var rsa = new RSAKey();
  	rsa = KEYUTIL.getKey(document.form1.prvkey1.value);
	var hSig = rsa.sign(document.form1.msgsigned.value, document.form1.hashalg.value);
	document.form1.siggenerated.value = utf8tob64(hSig);
}
</script>
<style type="text/css">
TD  {vertical-align: top}
</style>
</head>
<body>
<h1>Sample Application for RSA signing in JavaScript</h1>

<form name="form1">
<table border="0">
<tr>
<td>
PEM RSA Private Key<br/>
<!-- _test/z5.* for X.509v1 certificate and private key -->
<textarea name="prvkey1" rows="15" cols="65">
-----BEGIN PRIVATE KEY-----
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALymXlL8dgo9UTs+y//3P4gV1SHWsLgP4eqCpRQiXrZkvt0+j7cED+KESFUAGfw++hsnJUGqnWRvn6nGLrGn0AxPK+QAEg7In9PcwpgYlKV7oPQPBuFs1XwF7R5TIvBoDt1R/ACzJ7jMxRTx+2vsXp5EbiYcbHDXThMLZxVf64QDAgMBAAECgYEAjxpc3vKn0CinYBvIwAicZuy42oxzTYyuwSgNdXKFCjLuHgKBHkG0kw3pmKEVFSXor4RIXMHB1xhds3mknhtAU2hojp0jfxhJnaZHnQ+agU87b3DyqnnTqI9CIOLkRYTqDJVSzkKAcUXFkyPl4+a0v11gbIiogzbYoxaMZcf+jIECQQDklNeeVO1L8R+WbsKhhjKHFgdhstl3xVvfSROoERRmqeKVc6YM1DVoEJgey0LUxdk+DTh48Egf7figtGUYMQYhAkEA00dUXMjRoWJT6yz1d8JN896RnLSLjeClR7zprPLQ/WPxHDZwT9e4tbD4ka6Hd+NihodvtVE73YNWCpdahOb9owJBAIAg7rxR3rIy9wHcFD12e9w8/OZG2p/IgTcoP1x2NnlVwS0FJo8KZOVwZ9TbGxspzBx8TKt+BO/g9P0gIYrt8AECQDstG1/xj2WYWNDiAs7MSXEowbgWiY/vf9ub+gdK62ZNe9bfGI4EaePZ8YU8UQ0vTwVHIe6zFgVxJ8RHqD7ZQ+kCQEKWH7P/aaS8iLF9f1d5lsor+uPIq5o5j3FmbRFJdKc8NnrAE6h9+hGNe73oxn1iSA9jmhFJZ+nbPskpaSSFL70=
-----END PRIVATE KEY-----
</textarea><br/>
Text message to be signed.<br/>
<input type="text" name="msgsigned" size="63" value="aaa"/><br/>
</td>
<td></td>
</tr>

<tr>
	<td>
	<select name="hashalg">
		<option value="sha256">SHA256
	</select>
	<input type="button" value="Sign to this message &darr;" onClick="doSign();"/><br/>
	</td>
</tr>

<tr>
<td>
	Generated Signature<br/>
	<textarea name="siggenerated" rows="12" cols="65"></textarea>
</td>
</tr>
<tr>
<td>
Signer's Public Key Certificate.<br/>
<textarea name="cert" rows="12" cols="65">
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8pl5S/HYKPVE7Psv/9z+IFdUh1rC4D+HqgqUUIl62ZL7dPo+3BA/ihEhVABn8PvobJyVBqp1kb5+pxi6xp9AMTyvkABIOyJ/T3MKYGJSle6D0DwbhbNV8Be0eUyLwaA7dUfwAsye4zMUU8ftr7F6eRG4mHGxw104TC2cVX+uEAwIDAQAB
-----END PUBLIC KEY-----
</textarea><br/>
</td>
</tr>

</table>
</form>
</body>
</html>
